//-------------------------------------------------------------------------
/**
   File:   EnvironmentBlock.h

   Descr.: - todo -

   Author: Stefan Leihkauf
   Date:   28.07.2013
*/
//-------------------------------------------------------------------------
#ifndef _ENVIRONMENTBLOCK_H
#define _ENVIRONMENTBLOCK_H
#include "common/types/typedef.h"
#include "EnvironmentString.h"

namespace cb { namespace process {

//-------------------------------------------------------------------------
/* class holding an environment block (a list of environment strings)
*/
class EnvironmentBlock
{
	static const StdString terminationString;
	EnvironmentStringList _environment;

public:
	typedef std::vector<StdString> StringList;

	typedef EnvironmentStringList::iterator iterator;
	typedef EnvironmentStringList::const_iterator const_iterator;

public:
	// construction
	inline EnvironmentBlock();

	// add/remove environment string
	void add(const EnvironmentString& e);
	void remove(const EnvironmentString& e);

	// find environment strin by name 
	const EnvironmentString& find(const StdString& name) const;

	// get number of environment strings
	inline unsigned size() const;
	inline bool empty() const;

	// number of characters
	unsigned length() const;

	// iteration support
	inline const_iterator begin() const;
	inline iterator begin();

	inline const_iterator end() const;
	inline iterator end();

	// convert to stringlist
	// as for the rules of environment blocks the stringlist is terminated
	// by an empty string
	StringList toString() const;

	// equality
	bool operator == (const EnvironmentBlock& other) const;
};

#include "process/EnvironmentBlock.hpp"

}} // namespace cb::process

#endif //!defined _ENVIRONMENTBLOCK_H